package com.youren.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.youren.health.constant.MessageConstant;
import com.youren.health.entity.Result;
import com.youren.health.pojo.Setmeal;
import com.youren.health.service.SetmealService;
import com.youren.health.utils.OSSUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @program: health_parent
 * @author: You_ren_a
 * @create: 2020-11-29 00:13
 **/

@RestController
@RequestMapping("/setmeal")
public class SetmealMobileController {

    @Reference
    private SetmealService setmealService;

    @GetMapping("/getSetmeal")
    public Result getSetmeal(){
        List<Setmeal> setmealList = setmealService.findAll();
        return new Result(true , MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmealList);
    }
    
    @GetMapping("/findDetailById")
    public Result findDetailById(Integer id){
        Setmeal setmeal = setmealService.findDetailById(id);
        return new Result(true , MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }

    @PostMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setmealService.findById(id);
        setmeal.setImg(OSSUtil.DOMAIN+setmeal.getImg());
        return new Result(true , MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }

}
